package com.example.provider.controller;

import com.example.common.entity.Invite;
import com.example.common.entity.Message;
import com.example.provider.service.CompanyService;
import com.example.provider.service.InviteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/invite")
@Api(value = "邀请controller", tags = {"公司邀请工作室相关接口"})
public class InviteController {
    @Autowired
    private InviteService inviteService;

    @ApiOperation("添加企业对工作室的邀请")
    @ResponseBody
    @PostMapping("/addInvitation")
    public Message addInvitation(@RequestBody Map<String, Long> map){
        long ll = map.get("workroomId");
        return inviteService.addInvitation(map.get("demandId"),
                Integer.parseInt(String.valueOf(ll)),
                Integer.parseInt(String.valueOf(map.get("companyId"))));
    }

    @ApiOperation("工作室查看公司发起的邀请")
    @ApiImplicitParam(name = "workroomId",paramType = "query")
    @GetMapping("/checkInvitation")
    public List<Invite> checkInvitation(int workroomId){
        return inviteService.checkInvitation(workroomId);
    }

    @ApiOperation("公司查看工作室对邀请的回复")
    @ApiImplicitParam(name = "companyId",paramType = "query")
    @GetMapping("/checkReply")
    public List<Invite> checkReply(int companyId){
        return inviteService.checkReply(companyId);
    }

    @ApiOperation("工作室回复邀请，若接受项目进入开工状态")
    @ResponseBody
    @PostMapping("/replyInvitation")
    public Message replyInvitation(@RequestBody Map<String, Long> map){
        return inviteService.replyInvitation(map);
    }

}
